#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int N=3e5+10;
int c1[N];
int c2[N];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
	    string s;
	    cin>>n>>s;
	    int num1=0,num2=0;
	    string s1=s;
	    for(int i=0;i<s.size();i++)
	    {
	    	if(s[i]=='(') num1++;
	    	else num2++;
		}
		if(num1!=num2)
		{
			cout<<-1<<endl;
			continue;
		}
		
		int cnt1=1;
		int l=0,r=0;
		int res1=0;
		for(int i=n-1;i>=0;i--)
		{
			if(s[i]=='(')
			{
				l++;
				if(l>r)
				{
					cnt1=2;
					c1[i]=cnt1;
					res1++;
				}
			}
			else r++;
		}
		reverse(s1.begin(),s1.end());
		int cnt2=1;
		l=0,r=0;
		int res2=0;
		for(int i=n-1;i>=0;i--)
		{
			if(s1[i]=='(')
			{
				l++;
				if(l>r)
				{
					cnt2=2;
					c2[i]=cnt2;
					res2++;
				}
			}
			else r++;
		}
		int ans=min(cnt2,cnt1);
		cout<<ans<<endl;
		if(cnt1<=cnt2)
		{
			for(int i=0,idx=2;i<n;i++)
		    {
		    	if(res1==0) break;
			    if(s[i]==')')
			    {
				    c1[i]=2;
				    res1--;
			    }
		    }
		    for(int i=0;i<n;i++)
		    {
		    	if(c1[i]==0) cout<<1<<' ';
		    	else cout<<c1[i]<<' ';
		    	c1[i]=0; c2[i]=0;
		    }
		    cout<<endl;
		}
		
		else
		{
			for(int i=0,idx=2;i<n;i++)
		    {
		    	if(res2==0) break;
			    if(s[i]==')')
			    {
				    c2[i]=2;
				    res2--;
			    }
		    }
		    for(int i=0;i<n;i++)
		    {
		    	if(c2[i]==0) cout<<1<<' ';
		    	else cout<<c2[i]<<' ';
		    	c1[i]=0; c2[i]=0;
		    }
		    cout<<endl;
		}

	}

	return 0;
}

